package dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import util.DBUtil;

import dao.AccountDao;
import entity.Account;

public class AccountDaoJdbcImpl implements AccountDao {

	@Override
	public Account findByAccount(String account) throws Exception {
		String sql="select * from account where account=?";
		Connection con=DBUtil.openInThread();
		PreparedStatement pst=con.prepareStatement(sql);
		pst.setString(1, account);
		ResultSet rs=pst.executeQuery();
		Account a = null;
		if(rs.next()){
			a=new Account();
			a.setAccount(rs.getString("account"));
			a.setBalance(rs.getDouble("balance"));
		}
		return a;
	}

}
